import Mock from 'mockjs'
const userList = [{
	username: 'admin',
	password: 'admin',
}, {
	username: '1907A',
	password: '29',
}, {
	username: '网站工程',
	password: '未知',
}]
const data = Mock.mock({
	'banners|5': ['@image(375x150, @color)'],
	'list|100': [{
		'url': '@image(100x100, @color)',
		'title': '@ctitle',
		'desc': '@cword(10, 20)',
		'id': '@id'
	}]
})


Mock.mock('/api/banners', () => ({ code: 200, data: data.banners }))
Mock.mock('/api/list', () => ({ code: 200, data: data.list }))
Mock.mock('/api/login', 'post', (req) => {
	const { username, password } = JSON.parse(req.body)
	const isExit = userList.some(item => item.username === username && item.password === password)

	if(isExit) {
		return {
			code: 200,
			mess: '登录成功！！',
			token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
		}
	} else {
		return {
			code: 403,
			mess: '账户密码错误， 请重新输出！'
		}
	}
})